
// 3.给定一个字符串,查找出字符串最长单词的长度 例如:var str='Grasp the present';返回最长单词的长度
function Longer(str) {
    var maxLong = 0;
    var index = [];
    for (var i = 0; i < str.length; i++) {
        if (str[i].length > maxLong) {
            maxLong = str[i].length;
            index = str[i];
        }

    }
    console.log(index);
    console.log(maxLong);

}

var str = 'Grasp the present';
var result = str.split(' ');
Longer(result);

